package demo;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * 角色判断表达式
 * @author ZhouWeiBo
 * @create 2022/6/8
 */
public class RoleExpression implements Expression{

    private final Set<Role> roles = new HashSet<>();

    public RoleExpression(Role[] roles) {
        this.roles.addAll(Arrays.asList(roles));
    }

    @Override
    public boolean interpret(Person person) {
        return roles.contains(person.getRole());
    }
}
